package object;

public class ObjectDemo {
    public static void main(String[] args) {
        Point p1=new Point(100,200);
        Point p2=new Point(100,200);
        System.out.println(p1==p2);
        System.out.println(p1.equals(p2));

        //String类重写了equals()来比较字符串内容是否相同
        String s1=new String("hello");
        String s2=new String("hello");
        System.out.println(s1.equals(s2));

        //StringBuilder类没有重写equals(),因此调用的还是Object类的equals()比较地址
        StringBuilder builder1=new StringBuilder("hello");
        StringBuilder builder2=new StringBuilder("hello");
        System.out.println(builder1.equals(builder2));
        //类型不同 直接false
        System.out.println(s1.equals(builder1));

        /*
        输出引用变量时默认调用Object类的toString()方法
        该方法返回的字符串对我们的开发是没有意义的
        真正想输出的应该是对象的属性值
        因此我们常常重写toString()来返回具体的属性值
         */
        /*
        Point p=new Point(100,200);
        System.out.println(p);
        System.out.println(p.toString());


         */

    }
}
